package com.moyq5.spring.boot.app.register.client;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessagingException;
import org.springframework.stereotype.Component;

import com.moyq5.spring.boot.app.register.AppInfoSimple;
import com.moyq5.spring.boot.app.register.AppListener;
import com.moyq5.spring.boot.app.register.utils.JSON;

/**
 * “应用”注册监听
 * @author Moyq5
 * @date 2019年3月6日
 */
@Component("appInfoClientHandler")
public class AppInfoHandler implements MessageHandler {
 
	@Autowired
	private AppListener appInfoClientListener;
	@Override
	public void handleMessage(Message<?> message) throws MessagingException {
		String json = String.valueOf(message.getPayload());
		appInfoClientListener.update(JSON.toObject(json, AppInfoSimple.class));
	}

}
